<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateSmsCodeRecord extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sms_code_record', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('mobile')->default(0);
            $table->string('code', 8)->default('')->comment("验证码");
            $table->string('smsClient', 20)->default('')->comment("短信服务商");
            $table->unsignedInteger('type')->default(0)->comment('验证码类型 0:默认 1:注册 2:忘记密码');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('expiredAt')->default(0)->comment('过期时间');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");

            $table->index('mobile', 'mobile_idx');
            $table->index('expiredAt', 'expiredAt_idx');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '短信发送记录表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sms_code_record');
    }
}
